<template>
	<div class="modal-list">
		<div>
			<div class="new-modal-title">
				分配
				<i class="ion-close-round delete" @click="rDelete(false)"></i>
			</div>
			<div class="reserve" style="height: 100vh; overflow-y: auto;">
				<form @submit.prevent="genderDeletes">
					<ul>
						<li>
							<div class="car-editor-title">
								分配员工
							</div>
							<list>
								<item>
									<div class="car-enitor-screen car-editor-tr active">
										<div v-for="(item,index) in screen" >
											<input type="radio" :id="index" :value="item.userId" @click="radioChange(index)" v-model="checkedNames.id">
		  									<label :for="index" :class="{on:checkedNames.id==item.userId}" >{{item.userName}}</label>
		  									<div v-if="checkedNames.id==item.userId">
			  									<input type="text" name="followerId"  v-model="item.userId" >
			  									<input type="text" name="followerName"  v-model="item.userName" >
		  									</div>
										</div>
									</div>
									<!-- {{checkedNames.name}} -->
								</item>
							</list>
						</li>
						<li>
							<list>
								<item>
									<div class="car-editor-tr active">
										<div class="car-editor-name">下次跟进时间</div>
										<div class="car-editor-input" style="width:200px;">
											<input type="date" style="width:200px;" v-model="svreenDate" name="nextFollowDatetime">
										</div>
									</div>
								</item>
								<item style="text-align: center">
									<button class="screen-submit" type="submit">确定</button>
								</item>
							</list>
						</li>					
					</ul>
					<input type="text" name="customerShopId" v-model="customerShopId" class="none" >
				</form>
			</div>		
		</div>
	</div>
</div>
</template>

<script>
	export default{
		data(){
			return{
				screen:[],
				checkedNames:{
					id:'',
					name:''
				},
				svreenDate:''		
			}
		},
		methods:{
			genderDeletes(event){

				// this.$emit('cancelt',true})
				if(this.checkedNames.id==''){
					$toast.show('请选择员工', 2000)
					return false
				}

				if(this.svreenDate==''){
					$toast.show('请选择时间', 2000)
					return false
				}
				

				let formData = new FormData(event.target)
				axios.post(baseUrl+'/crm-web/controller/customer/allocate',formData).then((res)=>{
					// console.log(res)
					if(res){
						setTimeout(()=>{
							$toast.show('修改成功', 1000)
							setTimeout(()=>{
								this.rDelete(true)
							},1000)							
						},500)
					}
				})
			},
			radioChange(index){
				this.checkedNames.name = this.screen[index].userName
			},
			rDelete(state){

				this.$emit('cancelt',state)
			}
		},
		created(){
			window.axios.get(baseUrl+'/crm-web/controller/customer/queryUserList',{params:{
				marketId:sess.get('userSession').marketId,
       			shopId:sess.get('userSession').shopId
			}}).then((res)=>{
				this.screen = res.data.result
				// console.log(this.screen)
			})
		},
		mounted(){
			
		},
		props:[
			'customerShopId'
		]
	}
</script>
<style scoped="scoped">
	.screen-submit{ width: 40%; display: inline-block; vertical-align: middle; height: 40px; border-radius: 5px;border:0 none; outline: 0 none; margin: 10px auto;background: #FF6816; color: #fff;}
	.screen-submit.on{ border-radius: #fff; color:#FF6816; border:1px solid #FF6816; background: none; }
</style>

